package com.qdlc.p2p.biz.model;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.qdlc.p2p.common.util.StringUtil;
import com.qdlc.p2p.dal.common.model.jpa.PageDataList;
import com.qdlc.p2p.dal.model.AppIndexVO;
import com.qdlc.p2p.dal.model.BorrowModel;

public class AppIndexModel {
	
	private Map<String,Object> data;
	/**
	 * App首页响应
	 * @return
	 */
	public Map<String,Object> indexResponse(PageDataList<BorrowModel> borrowModelList){
		List<BorrowModel> list = borrowModelList.getList();
		data = new HashMap<String,Object>();
		List<AppIndexVO> list_ = new ArrayList<AppIndexVO>();
		if(list.size() < 1){
			data.put("data", list);
		}else{
			for(BorrowModel borrowModel_ : list){
				AppIndexVO appIndexVO = new AppIndexVO();
				appIndexVO.setAccount(borrowModel_.getAccount());
				appIndexVO.setApr(borrowModel_.getApr());
				appIndexVO.setAwardAccount(borrowModel_.getPartAccount());
				appIndexVO.setCategory(borrowModel_.getCategory());
				appIndexVO.setContent(borrowModel_.getContent());
				appIndexVO.setId(borrowModel_.getId());
				appIndexVO.setStyle(borrowModel_.getStyle());
				appIndexVO.setImageArray(null);//首页图片
				appIndexVO.setIsDay(borrowModel_.getIsDS());
				appIndexVO.setIsMb(StringUtil.isBlank(borrowModel_.getInPwd()) ? 0 : 1);
				appIndexVO.setTimeLimitTip(borrowModel_.getTimeLimitTip());
				appIndexVO.setType(borrowModel_.getType());
				appIndexVO.setScale(borrowModel_.getScales());
				appIndexVO.setStatus(borrowModel_.getStatus());
				appIndexVO.setName(borrowModel_.getName());
				appIndexVO.setTimeLimit(borrowModel_.getTimeLimit());
				list_.add(appIndexVO);
			}
			data.put("data", list);
		}
		data.put("resCode", "1");
		return data;
	}
}
